//
//  ZWBChannelCell.m
//  Cat
//
//  Created by dllo on 15/11/27.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "ZWBChannelCell.h"
#define CWIDTH self.contentView.frame.size.width
#define CHEIGHT self.contentView.frame.size.height
@implementation ZWBChannelCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self create];
    }
    return self;
}


- (void)create {
    
    self.typeImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.typeImageView];
    
    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.nameLabel];
    
    self.fansLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.fansLabel];
    
    
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    

    _fansLabel.textColor = [UIColor grayColor];
    _fansLabel.font = [UIFont systemFontOfSize:10];
    
    
    [self.typeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(10);
        make.top.equalTo(self.contentView.mas_top).offset(10);
//        make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
        make.width.mas_equalTo((CWIDTH - 10)/ 7);
        make.height.mas_equalTo((CWIDTH - 10)/7);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.typeImageView.mas_right).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
        make.top.equalTo(self.contentView.mas_top).offset(10);
        make.height.mas_equalTo((CHEIGHT - 20) * 3/7);
        
    }];
    
    [self.fansLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.typeImageView.mas_right).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(10);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
    }];
    
    _typeImageView.layer.masksToBounds = YES;
    _typeImageView.layer.cornerRadius = (CWIDTH - 10)/ 7/2;
    
}

- (void)setModel:(ChannelModel *)model {
    
    [self.typeImageView sd_setImageWithURL:[NSURL URLWithString:model.url]placeholderImage:[UIImage imageNamed:@"ooopic_1445565008@2x.png"]];
    self.nameLabel.text = model.channelName;
    self.fansLabel.text = [NSString stringWithFormat:@"%@人关注",model.fans];
    
}


- (void)awakeFromNib {
    // Initialization code
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
